import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.Properties;
@MyAnno(ClassName = "entity.Person",Method = "eat")
public class Reflect2 {
    public static void main(String[] args) throws Exception {

//        Properties property = new Properties();
//        ClassLoader classLoader = Reflect2.class.getClassLoader();
//        InputStream resourceAsStream = classLoader.getResourceAsStream("entity/pro.properties");
//        property.load(resourceAsStream);
//        String className = property.getProperty("ClassName");
//        String method = property.getProperty("Method");

        Class<Reflect2> cls = Reflect2.class;
        MyAnno myAnno = cls.getAnnotation(MyAnno.class);
        String className = myAnno.ClassName();//相当于一个子类实现了这个接口，调用其中的方法
        String method = myAnno.Method();

        Class cls_targrt = Class.forName(className);
        Object obj = cls_targrt.newInstance();
        Method m = cls_targrt.getMethod(method);
        m.invoke(obj);
    }
}